cmake_minimum_required(VERSION 3.10)
project(ListExample)

# 初始化列表
set(list1 "apple" "banana" "cherry")

# APPEND: 向列表末尾添加元素
list(APPEND list1 "date")
message(STATUS "List after append: ${list1}")

# INSERT: 在指定位置插入元素
list(INSERT list1 1 "orange")
message(STATUS "List after insert: ${list1}")

# REMOVE_ITEM: 从列表中移除指定元素
list(REMOVE_ITEM list1 "banana")
message(STATUS "List after remove item: ${list1}")

# REMOVE_AT: 移除列表中的指定位置的元素
list(REMOVE_AT list1 1)
message(STATUS "List after remove at: ${list1}")

# SORT: 对列表进行排序
list(SORT list1)
message(STATUS "List after sort: ${list1}")

# GET: 获取列表中的指定元素
list(GET list1 1 result)
message(STATUS "Element at index 1: ${result}")

# LENGTH: 获取列表的长度
list(LENGTH list1 length)
message(STATUS "Length of list: ${length}")

# FIND: 查找元素在列表中的位置
list(FIND list1 "cherry" cherry_index)
message(STATUS "Index of 'cherry': ${cherry_index}")

set(list1 "a;b;b;c;d")
list(RREMOVE_DUPLICATES list1)
message(STATUS "List after remove duplicates: ${list1}")